package com.cloud.wms.ui.inside.replenish;

import android.content.Intent;
import android.os.Message;

import com.cloud.core.config.EventConfig;
import com.cloud.core.eventBus.Event;
import com.cloud.core.eventBus.EventBusUtil;
import com.cloud.widget.ScanText;
import com.cloud.wms.R;
import com.cloud.wms.base.BaseBarActivity;
import com.cloud.wms.config.IntentKey;
import com.cloud.wms.ui.inside.contract.ReplenishApplyContact;
import com.cloud.wms.ui.inside.presenter.ReplenishApplyPresenter;

import butterknife.BindView;

/**
 * Created by FC on 2021/3/12.
 * Desc：补货申请扫描库位
 */
public class ApplyStartActivity extends BaseBarActivity<ReplenishApplyPresenter> implements ReplenishApplyContact.View {
    @BindView(R.id.scan_text)
    ScanText scanText;

    @Override
    protected String barTitle() {
        return "补货申请";
    }

    @Override
    protected int getResId() {
        return R.layout.activity_replenish_apply_start;
    }

    @Override
    protected void onScanHandle(String result, int resultCode) {
        super.onScanHandle(result, resultCode);
        scanText.addHistory(result);
        mPresenter.checkReplenishApplyPos(result);
    }

    @Override
    protected void initEvent() {
        initScanText(scanText);
    }

    @Override
    public void onSuccess(Message message) {
        if (message.what == ReplenishApplyPresenter.CHECK_POS) {
            Intent intent = new Intent(this, ApplyCommodityActivity.class);
            intent.putExtra(IntentKey.INFO_KEY, message.obj.toString());
            startActivity(intent);
        }
    }

    @Override
    protected void setupComponent() {
        getActivityComponent().inject(this);
    }
}
